<template>
  <div>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" icon="" size="mini" @click="exportExcel">一键赠送</el-button>
      </el-col>
    </el-row>
    <el-table height="400px" :data="list" @selection-change="handleSelectionChange" stripe border>
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" prop="index" align="center" width="60" />
      <el-table-column label="用户UID" prop="userId" align="center" />
      <el-table-column label="消费券数额" prop="amount" align="center" width="100" />
      <el-table-column label="说明" prop="remark" min-width="250" />
    </el-table>
  </div>
</template>

<script>
import { Console } from 'console';

export default {
  props: {
    list: {
      type: Array
    }
  },
  data() {
    return {
      selectArray: []
    }
  },

  methods: {
    handleSelectionChange(val) {
      this.selectArray = val;
    },

    exportExcel() {
      var isPass = 1;

      this.selectArray.forEach((item, index, array) => {
        let userId = String(item.userId);
        let amount = String(item.amount);
        userId = userId.replace(/\s*/g, "")
        amount = amount.replace(/\s*/g, "")
        item.userId = userId;
        item.amount = amount;
      })

      if (isPass) {
        this.$emit('submit', this.selectArray)
      }
    }
  }

}
</script>

<style>
</style>
